﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using kim.Common;

namespace kim
{
     partial class Login : System.Web.UI.Page
    {
       
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }
        protected void loginsubmit_Click(object sender, ImageClickEventArgs e)//提交
        {

            string userName = txtUserName.Text.Trim();
            string userPwd = txtUserPwd.Text.Trim();
            BLL.eg_Admin bll = new BLL.eg_Admin();
            Model.eg_Admin model = bll.GetModel(userName, DESEncrypt.Encrypt(userPwd));
            if (model==null)
            {
                lbMsg.Text = "用户名或密码有误！";
                return;
            }
            if (model.State == 1)
            {
                bll.Update(model.ID);//更新登录数
                Session[KIMKeys.SESSION_ADMIN_INFO] = model;
                Session.Timeout = 50;
                Utils.WriteCookie("AdminName", "KIM", model.AdminName);
                Utils.WriteCookie("AdminPwd", "KIM", model.AdminPwd);
                Response.Redirect("indexpage.aspx");
                return;
            }
            else
            {
                lbMsg.Text = "用户已经被锁定，无法登录！";
            }
        }
     
    }
}